<?php
function JudgeNetIp($ip,$mask)
{
	return  long2ip(bindec((decbin(ip2long($ip)) & decbin(ip2long($mask)))));
}

function GetBroadCast($ip, $mask)
{
	$mask_bin = decbin(ip2long($mask));
	$ip_bin = decbin(ip2long($ip));

	print $ip_bin. '\n'. $mask_bin;
	print '\n';
	
	$bin = ( $ip_bin | (~$mask_bin)) ;
	print "\n". $bin;
	$ret = long2ip (bindec($bin));
	return $ret;
}


function GetMaskLen($mask)
{
	$tmp = decbin(ip2long($mask));
	foreach (count_chars($tmp, 1) as $i => $val)
	{
		if ($i == 49 )
			return  $val;
	}
}

?>

